package com.iplay.headfirst.chapter1;

/**
 * 鸭超类
 * @author dangwu
 * @since 2021/3/10 12:53 下午
 */
public abstract class BaseDuck {
    private QuackBehavior quackBehavior;
    private FlyBehavior flyBehavior;

    public BaseDuck(){}

    public void performQuack(){
        //委托模式无处不在
        quackBehavior.quack();
    }

    public void swim(){
        System.out.println("=======游泳=======");
    }

    public void performFly(){
        flyBehavior.fly();
    }
    /**
     * 外观
     */
    public abstract void display();

    public QuackBehavior getQuackBehavior() {
        return quackBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

    public FlyBehavior getFlyBehavior() {
        return flyBehavior;
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }
}
